#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e6 + 5;
int a[maxn], vis[maxn];

int main()
{
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, jsq = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    if (n > 1000)
    {
         if (n % 2 == 0)
         {
             cout << n / 2 - 1 << endl;
             return 0;
         }
        else
        {
            cout << (n - 1) / 2 << endl;
            return 0;
        }
    }

    memset(vis, sizeof vis, 0);

    for (int i = 1; i <= n; i++)
    {
        if (vis[i] == 0)
        {
            for (int j = 1; j <= n; j++)
            {
                if (a[j] == a[i])
                {
                    jsq++;
                    vis[i] = 1;
                }
            }
        }


        if (n % 2 == 0)
        {
            if (jsq >= n / 2)
            {
                cout << jsq << "\n";
                return 0;
            }
            else break;
        }
        else
        {
            if (jsq >= (n + 1) / 2)
            {
                cout << jsq << "\n";
                return 0;
            }
            else break;
        }
        jsq = 0;
    }
    if (n % 2 == 0) cout << n / 2 - 1 << endl;
    else cout << (n - 1) / 2 << endl;
    return 0;
}
